// JavaScript Document

//弹出框

function swal_alert(title,type,text){
	
	 
	if(!title){
		title='Message';
	}
	if(type==1){
		type='success';	
	}else if(type==0){
		type='error'	
	}
	swal(title, text, type);
	
	
	
}
//确认提示框

function swal_confirm(title,success_function,fail_function,text,type){
	
	 if(!title){
		title='确定执行此操作？';
	 }
	 swal({
	  title: title,
	  text: text,
	  type: type,
	  showCancelButton: true,
	  confirmButtonColor: "#DD6B55",
	  confirmButtonText: "确定",
	  cancelButtonText: "取消",
	  closeOnConfirm: false,
	  closeOnCancel: true
	},
	function(isConfirm){
	  if (isConfirm) {
		success_function
	  } else {
		fail_function
	  }
	});
	
	
}

//ajax请求

function ajax(url,data,method){
	 $.ajax({
	   url: "page.php",
	   data:data,
	   dateType:"json",
	   success: handleResponse
	 });
	
}

//退出登录

function loginOut(){
	 swal({
	  title: "确认退出？",
	  text: "退出后需重新登录",
	  type: "",
	  showCancelButton: true,
	  confirmButtonColor: "#DD6B55",
	  confirmButtonText: "确定",
	  cancelButtonText: "取消",
	  closeOnConfirm: false,
	  closeOnCancel: true
	},
	function(isConfirm){
	  if (isConfirm) {
		 $.ajax({
		   url: "/core/loginOut.html?is_ajax=1",
		   success: function(data){
			   if(data){
				   
				   
				   swal({title:"退出成功",  text:"3秒后自动跳转",  type:'success'}, function(data){
					   
					   location.href='/core/login.html';
					   
				  });
				   setTimeout("location.href='/core/login.html'",3000)
			   }else{
				   swal_alert("退出成功",0)
			   }
		   }
		 });
	  } 
	});
	
	
	
	 
}
